# Contributor: Ted Trask <ttrask01@yahoo.com>
# Maintainer: Ted Trask <ttrask01@yahoo.com>
_luaversions="5.1 5.2 5.3 5.4"
pkgname=acf-lib
pkgver=0.11.1
pkgrel=0
pkgdesc="Lua libraries for ACF"
url="https://gitlab.alpinelinux.org/acf/acf-lib"
arch="noarch"
license="GPL-2.0-only"
options="!check" # no test suite
depends="lua-subprocess"
for _i in $_luaversions; do
	subpackages="$subpackages acf-lib-lua$_i:split_${_i/./_}"
done
source="https://gitlab.alpinelinux.org/acf/acf-lib/-/archive/v$pkgver/acf-lib-v$pkgver.tar.gz"
builddir="$srcdir/$pkgname-v$pkgver"

package() {
	mkdir -p "$pkgdir"
	echo "package with pkgdir=$pkgdir"
	for _i in $_luaversions; do
		sed "s~luadir=.*~luadir=\${prefix}/share/lua/$_i/acf~" -i config.mk
		make DESTDIR="$pkgdir-lua$_i" install
	done
}

_split() {
	local _ver=$1
	pkgdesc="Lua $_ver libraries for ACF"
	install_if="lua$_ver $pkgname=$pkgver-r$pkgrel"
	replaces="$pkgname"
	depends=""
}

for _i in $_luaversions; do
	eval "split_${_i/./_}() { _split $_i; }"
done

sha512sums="
7ad8cfe6475f7febaaf0ed8774d78d4e53a4ebfa0de9d65249b0c4c1ef316211c4d3e5339dc502f8c8d27906f6c8b3e54a74e3b5d00b8b5cf26e6b01861b2aef  acf-lib-v0.11.1.tar.gz
"
